ExternalProject_Add(llvm-host-libcxx
    DOWNLOAD_COMMAND ""
    UPDATE_COMMAND ""
    SOURCE_DIR ${LLVM_SRC}
    LIST_SEPARATOR ^^
    CONFIGURE_COMMAND ${EXEC_HOST} ${CMAKE_COMMAND} -H<SOURCE_DIR>/runtimes -B<BINARY_DIR>
        -GNinja
        -DCMAKE_BUILD_TYPE=Release
        -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
        -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
        -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
        -DCMAKE_ASM_COMPILER=${CMAKE_C_COMPILER}
        -DCMAKE_C_COMPILER_WORKS=ON
        -DCMAKE_CXX_COMPILER_WORKS=ON
        -DCMAKE_ASM_COMPILER_WORKS=ON
        -DCMAKE_DISABLE_FIND_PACKAGE_LLVM=ON
        -DCMAKE_DISABLE_FIND_PACKAGE_Clang=ON
        -DLLVM_ENABLE_RUNTIMES='libunwind^^libcxxabi^^libcxx'
        -DLIBUNWIND_USE_COMPILER_RT=ON
        -DLIBUNWIND_ENABLE_SHARED=OFF
        -DLIBUNWIND_ENABLE_STATIC=ON
        -DLIBCXX_ABI_UNSTABLE=ON
        -DLIBCXX_USE_COMPILER_RT=ON
        -DLIBCXX_ENABLE_SHARED=OFF
        -DLIBCXX_ENABLE_STATIC=ON
        -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
        -DLIBCXX_INSTALL_MODULES=OFF
        -DLIBCXX_CXX_ABI=libcxxabi
        -DLIBCXX_INCLUDE_TESTS=OFF
        -DLIBCXXABI_INCLUDE_TESTS=OFF
        -DLIBUNWIND_INCLUDE_TESTS=OFF
        -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF
        -DLIBCXXABI_USE_COMPILER_RT=ON
        -DLIBCXXABI_USE_LLVM_UNWINDER=ON
        -DLIBCXXABI_ENABLE_SHARED=OFF
        -DLIBUNWIND_INCLUDE_DOCS=OFF
        -DLIBCXX_INCLUDE_DOCS=OFF
        -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
        -DLIBCXXABI_ENABLE_ASSERTIONS=OFF
        -DLIBUNWIND_ENABLE_ASSERTIONS=OFF
        -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
        "-DCMAKE_C_FLAGS='${tc_cflags} ${tc_compiler_rt} ${llvm_pgo}'"
        "-DCMAKE_CXX_FLAGS='${tc_cflags} ${tc_compiler_rt} ${llvm_pgo}'"
        "-DCMAKE_ASM_FLAGS='${tc_cflags} ${tc_compiler_rt} ${llvm_pgo}'"
    BUILD_COMMAND ${EXEC_HOST} ninja -C <BINARY_DIR>
    INSTALL_COMMAND ${EXEC_HOST} ${CMAKE_COMMAND} --install <BINARY_DIR>
    LOG_DOWNLOAD 1 LOG_UPDATE 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1
)

cleanup(llvm-host-libcxx install)
